<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>绑定样式</title>
    <script type="text/javascript" src="../js/vue.js"></script>
</head>
<body>
<div id="root">
    <div class="basic" :class="a" @click="changeMood">{{name}}</div>
    <div class="basic" :class="sx" @click="changeMood">{{name}}</div>
</div>
</body>
<script type="text/javascript">
    Vue.config.productionTip=false
    new Vue({
        el:'#root',
        data:{
            name:'楠籽坏女人',
            a:'normal'
        },
        methods:{
            changeMood(){
                const sx=['happy','sad','normal']

                const index =Math.floor(Math.random()*3)
                this.a =sx[index]
            }
        }
    })
</script>
</html>